import Http from '@/api/http';
import BindRequest from '@/structure/bindRequest';
import LoginResponse from '@/structure/loginResponse';
import User from '@/structure/user';

/**
 * 抽象oauth控制器
 */
abstract class AbstractOauthControlPanelApi extends Http {
  /**
   * 绑定
   * @param data 绑定请求
   * @return 响应
   */
  public bind(data: BindRequest): Promise<LoginResponse<User>> {
    return super.post0(`${this.getBase()}/bind`, data);
  }

  /**
   * 解绑
   * @return 响应
   */
  public unbind(): Promise<void> {
    return super.post0(`${this.getBase()}/unbind`);
  }

  /**
   * 查询绑定状态
   * @return 响应
   */
  public bindStatus(): Promise<boolean> {
    return super.get0(`${this.getBase()}/bindStatus`);
  }

  protected abstract getBase(): string;
}

export default AbstractOauthControlPanelApi;
